<html lang="en">
 <head>
     <meta charset="UTF-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>星级评分</title>
     <style>
         *{
             margin: 0;
             padding: 0;
         }
         div{
             line-height: 35px;
         }
         li{
             width: 24;
             height: 24;
             background: url(./star.png) no-repeat;
             float: left;
             list-style: none;
             margin: 5px;
             cursor: pointer;
             padding: 12px;

         }
     </style>
 </head>
 <body>
     <div>
         <ul>
             <li></li>
             <li></li>
             <li></li>
             <li></li>
             <li></li>
         </ul>
         <span></span>
     </div>
 </body>
 <script src="../jquery-3.6.3.js"></script>
 <script>
     var oldIndex = -1;
     var timer = null;
     $("li").mousemove(function(){
         clearTimeout(timer);
         var index = $(this).index();
         $('li').slice(0,index+1).css("background-image","url(./star_fill.png)");
         $('li').slice(index+1).css("background-image","url(./star.png)");
     })
    .mousemove(function(){
         timer = setTimeout(function(){
         $('li').slice(0,oldIndex+1).css("background-image","url(./star_fill.png)");
         $('li').slice(oldIndex+1).css("background-image","url(./star.png)");
 
     },200)
 })
 </script>
 </html>